import { playMode } from '@/utils/playConfig.js'
const player = {
	state: {
		playing:false,
		playList:[],
		currentIndex:0,
		songsList:[],
		id:0,
		mode:playMode.sequence,
		playingState:false,
	},
	mutations:{
		SET_PLAYING:(state, playing) =>{
			state.playing = playing;
		},
		SET_PLAYLIST:(state, playList)=> {
			state.playList =  playList 
		},
		SET_CURRENTINDEX:(state, currentIndex)=> {
			state.currentIndex = currentIndex
		},
		SET_SONGSLIST:(state, songsList)=> {
			state.songsList = songsList 
		},
		SET_ID :(state, id)=> {
			state.id = id 
		},
		SET_PLAY_MODE :(state,mode)=>{
			state.mode = mode
		},
		SET_PLAYING_STATE :(state,playingState)=>{
			state.playingState = playingState
			}
	},
	actions:{
		// 列表点击播放时
		playMusic({ commit }, playerInfo) {
		  commit('SET_PLAYLIST', playerInfo.playList);
		  commit('SET_CURRENTINDEX', playerInfo.currentIndex);
		  commit('SET_SONGSLIST', playerInfo.songsList);
		  commit('SET_ID', playerInfo.id);
		  commit('SET_PLAYING', playerInfo.playing);
		  commit('SET_PLAYING_STATE', true);
		  
		}
	}
}

export default player
